package com.example.demo.algorithm;

import java.util.Arrays;

/**
 * 项目名称：hello-6
 * 类 名 称：ShellSort2
 * 类 描 述：希尔排序测试
 * 创建时间：2020/11/29 10:11
 * 创 建 人：wangsheng
 */
public class ShellSort2 {

    public static void main(String[] args) {
        int[] arr = {99, 5, 69, 33, 56, 13, 22, 55, 77, 48, 12, 88, 2, 69, 99};

        for (int d = arr.length / 2; d > 0; d = d / 2) {

            for (int i = d; i < arr.length; i++) {

                for (int j = i - d; j >= 0; j = j - d) {
                    if (arr[j] > arr[j + d]) {
                        int temp = arr[j];
                        arr[j] = arr[j + d];
                        arr[j + d] = temp;
                    }

                }
            }

        }
        System.out.println(Arrays.toString(arr));
    }
}
